package practicedemo18;

public class practicedemo18 {
    public static void main(String[] args){
        /*生成10个随机数求出所有数字的和，平均值，低于平均值的个数*/

        int x[] = new int [10];
        //创建10个随机数
        for (int i = 0 ; i<10 ; i++){
            x[i] = (int)(Math.random()*100)+1; //生成一个1到100的随机数
        }
        System.out.print("十个随机数是：");
        for (int i = 0 ; i<10 ; i++){
            System.out.print(x[i]+"\t");
        }
        //求和
        int total = 0;
        for (int i = 0 ; i< x.length ; i++){
            total+=x[i];
        }
        System.out.println();
        System.out.print("和：");
        System.out.print(total);
        //求平均值
        double average = total / 10.0 ;
        System.out.println();
        System.out.print("平均值：");
        System.out.print(average);
        //求低于平均值的数
        System.out.println();
        System.out.print("低于平均值的数：");
        int key = 0;
        for (int i=0 ; i< x.length ; i++){
            if (x[i]<average){
                System.out.print(x[i]+" ");
                key++;
            }
        }
        System.out.println();
        System.out.print("总计有："+key+"个数字低于平均值");
    }
}
